<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../../inc/conn.asp"-->
<!--#include file="../common/u.asp"-->
<%links="auctions"%>
<%
id=checkstr(inHTML(request("id")))
if id<>"" then
  select case id
  case 3: sqlsearch=sqlsearch+" and mark=2 "  '已中标
  case 4: sqlsearch=" and (mark=3 or mark=4 or mark=5)" '已付款
  end select
end if

'分页-------------------------------------------------------
set Rs=server.CreateObject("ADODB.RecordSet")
sql="select count(sortid) from (Select ROW_NUMBER() OVER (order by endtime asc,id desc) as sortid,* From auctionsorder) as TempTable where 1=1 and uid='"&uid&"' "&sqlsearch&""
Pager_Pagesize=15 '每页记录数
Rs.open sql,conn,1,1
Pager_TotalRecord=Rs(0) '总记录数
Rs.close
Pager_PageCount=int((Pager_TotalRecord/Pager_Pagesize)+0.99999) '计算总页数
CurrentPage=Request("page") '当前页
if CurrentPage=0 then CurrentPage=1
'如果不为数字则直接设置页码为1
if isnumeric(CurrentPage)=False Or CurrentPage="" then
	CurrentPage=1
'如果当前页数大于总页数，则直接设置页码为1
elseif  Clng(CurrentPage)>Pager_PageCount then
	CurrentPage=1
end if
Fieldsname=" id,uid,pic,url,title,Itemnumber,bidmark,Endtime,price,Realprice,WarehouseTime,TransportCost,ServiceCost,TransferCost,rate,PackageTime,Weight,mark,BidsPrice,bail,type,addtime,sortid"
orderBy=" Order by sortid asc"
'拆分SQL语句，必须是select开头，有唯一标识的列
if instr("select",sql)<>-1 then
	if CurrentPage = 1 then
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize  & Fieldsname)
	else  
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize   & Fieldsname) & " and sortid >(select max(sortid) from (" & replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize * (CurrentPage - 1)  & Fieldsname) & orderBy & ") AA)"
	end if
end if
sql = sql & orderBy
Rs.open sql,conn,1,1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>代拍订单</title>
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.tabs.js"></script>
<script type="text/javascript">
//$(function(){
//	$('.reg_s_1').Tabs({
//		event:'click'
//	});
//});	
</script>
<SCRIPT LANGUAGE="JavaScript">
function adClick(ad, site) {
window.open(ad);
window.location = site;}
</script>
</head>
<body onload="givetime()">

<!--#include file="../../common/top.asp"-->





<div class="fullwidth">
	<div class="place ">
		<a href="/">首页</a> &gt; <a href="/user">会员中心</a> &gt; 代拍订单
	</div>
</div>
<!--main-->
<div class="fullwidth bg1">
	<div class="main">
		
		
		
		
		<!--#include file="../common/left.asp"-->
        
        
        
        
		
		<div class="right_show f_r">
			
			<div class="title_4">
				<h2>代拍订单</h2><div></div>
			</div>
			<div class="reg_box reg_s_1 account order_tab order_tab1">
				<ul class="tab_menu">
					<li<%if id="" then response.Write " class=""current"""%>><a href="/user/auctions">所有订单</a></li>
					<li<%if id="0" then response.Write " class=""current"""%>><a href="/user/auctions/0">竞标中</a></li>
					<li<%if id="1" then response.Write " class=""current"""%>><a href="/user/auctions/1">预约出价中</a></li>
					<li<%if id="2" then response.Write " class=""current"""%>><a href="/user/auctions/2">出价被超中</a></li>
					<li<%if id="3" then response.Write " class=""current"""%>><a href="/user/auctions/order/3">已得标</a></li>
					<li<%if id="4" then response.Write " class=""current"""%>><a href="/user/auctions/order/4">已付款</a></li>
				</ul>
				<div class="tab_box">
					<div>
						<p class="tip tip_3">订单中商品的包裹创建以及发货状况请在<a href="" class="blue_u">包裹管理</a>中确认。</p>
						<table class="stable stable_1 stable_2 stable_3">
							<tr style="line-height:18px">
								<th width="18%">商品</th>
								<th>得标价格</th>
								<th>转账费</th>
							  <th>日本运费</th>
							  <th>服务费</th>
							  <th>总费用</th>
							  <th>保证金</th>
								<th>二次结余<br />
							    金额</th>				
							</tr>
                            <%
							t=0
							do while not Rs.eof
							endtimes=endtimes+"endtimes["&t&"]="""&Rs("endtime")&""";"
							%>
							<tr>
								<td style="line-height:18px; padding-bottom:10px; padding-top:10px">
									<a href="/auctions/<%=rs("Itemnumber")%>.html?s=t"><img src="<%=rs("pic")%>" width="40" height="40" align="left" alt=""></a>
                                    <a title="<%=rs("title")%>" target="_blank" href="/auctions/<%=rs("Itemnumber")%>.html?s=t"><%=left(rs("title"),15)%>...</a>
								</td>
								<td><%if rs("Realprice")="-1" then response.Write "一" else response.Write rs("Realprice")&"日元"%></td>
								<td><%if rs("TransferCost")="-1" then response.Write "一" else response.Write rs("TransferCost")&"日元"%></td>
								<td><%if rs("TransportCost")="-1" then response.Write "一" else response.Write rs("TransportCost")&"日元"%></td>
								<td><%if rs("ServiceCost")="-1" then response.Write "一" else response.Write rs("ServiceCost")&"日元"%></td>
								<td><%
	                      if rs("Realprice")="-1" or rs("TransferCost")="-1" or rs("TransportCost")="-1" or rs("ServiceCost")="-1" then
						  response.Write "一"
						  else
							if rs("rate")="0" then
							response.Write ((cdbl(rs("Realprice"))+cdbl(rs("TransferCost"))+cdbl(rs("TransportCost"))+cdbl(rs("ServiceCost")))*web_rate)
							else
							response.Write ((cdbl(rs("Realprice"))+cdbl(rs("TransferCost"))+cdbl(rs("TransportCost"))+cdbl(rs("ServiceCost")))*cdbl(rs("rate")))
							end if
							response.Write "RMB"
						  end if
							%></td>
								<td><%=rs("bail")%>RMB</td>
								<td><%
	                      if rs("Realprice")="-1" or rs("TransferCost")="-1" or rs("TransportCost")="-1" or rs("ServiceCost")="-1" then
						  response.Write "一"
						  else
							if rs("rate")="0" then
							response.Write ((cdbl(rs("Realprice"))+cdbl(rs("TransferCost"))+cdbl(rs("TransportCost"))+cdbl(rs("ServiceCost")))*web_rate)-cdbl(rs("bail"))&"RMB <a href =""?payment="&rs("id")&"&page="&CurrentPage&""" class=""blue_u"">去付款</a>"
							else
							response.Write ((cdbl(rs("Realprice"))+cdbl(rs("TransferCost"))+cdbl(rs("TransportCost"))+cdbl(rs("ServiceCost")))*cdbl(rs("rate")))-cdbl(rs("bail"))&"RMB"
							end if
						  end if
							%></td>
							</tr>
                            <%
							t=t+1
							Rs.movenext
							loop
							Rs.close
							Set Rs=nothing
							%>
							
							
						</table>
<div class="clear20"></div>
						<div class="clear20"></div>
						<div class="clear20"></div>
						<div class="page">
							<%
							if CurrentPage<=1 then
							pageview="<a><</a>"
							else
							pageview="<a href='/user/auctions/order/"&id&"?page="&CurrentPage-1&"'><</a>"
							end if
							for tp = -10 to 9
							if Pager_PageCount>=tp+page and tp+page=>1  then 
							if trim(tp+page)=trim(request("page")) then
							pageview=pageview+"<a class='cur_page'>"&tp+page&"</a>"
							else
							pageview=pageview+"<a href='/user/auctions/order/"&id&"?page="&tp+page&"'>"&tp+page&"</a>"
							end if
							end if
							next
							if Pager_PageCount<CurrentPage+1 then
							pageview=pageview+"<a>></a>"
							else
							pageview=pageview+"<a href='/user/auctions/order/"&id&"?page="&CurrentPage+1&"'>></a>"
							end if
							response.Write pageview
							%>

			      </div>
						<div class="clear20"></div>

						<div class="clear20"></div>
					</div>
					
                    

					
				</div>
				<div class="clear20"></div>
				<div class="clear20"></div>
			</div>	
			
		</div>
		
		
	</div>
</div>

<div class="clear"></div>



<!--#include file="../../common/footer.asp"-->




<%if request("payment")<>"" and request.Form("t")<>"y" then%> 
<div class="pop_content">
<table width="100%" border="0" cellspacing="5" cellpadding="0">
<%set rss=conn.execute("select * from auctionsorder where uid='"&uid&"' and id="&request("payment")&"")%>
<form name="formreg" method="post" action="" onSubmit="return myjobchk();">
  <tr>
    <td align="center"><strong>竞拍商品二次付款</strong></td>
  </tr>
  <tr>
    <td align="center" style="width:100px">中标价格：<%=cdbl(rss("Realprice"))*web_rate%>RMB</td>
  </tr>
  <tr>
    <td align="center" style="width:100px">转账费：<%=cdbl(rss("TransferCost"))*web_rate%>RMB</td>
  </tr>
  <tr>
    <td align="center" style="width:100px">日本国内运费：<%=cdbl(rss("TransportCost"))*web_rate%>RMB</td>
  </tr>
  <tr>
    <td align="center" style="width:100px">服务费：<%=cdbl(rss("ServiceCost"))*web_rate%>RMB</td>
  </tr>
  <tr>
    <td align="center" style="width:100px">保证金：-<%=rss("bail")%>RMB</td>
  </tr>
  <tr>
    <td align="center" style="width:100px">
      <%
	  '应付金额
	  TwoMoney=((cdbl(rss("Realprice"))+cdbl(rss("TransferCost"))+cdbl(rss("TransportCost"))+cdbl(rss("ServiceCost")))*web_rate)-cdbl(rss("bail"))
	  '余额减少判断
	  isMoney=cdbl(TwoMoney)-cdbl(money)
	  %>
      应付结余金额 ：<input type="text" disabled="disabled" style="width:120px" value="<%=FormatNumber(TwoMoney,2,-1)%>RMB" /> 
      </td>
  </tr>
  
  <%if isMoney>0 then%>
  <tr>
    <td align="center">余额不足：<%=FormatNumber(isMoney,2,-1)%>RMB <a href="javascript:adClick('/user/funds/recharge?money=<%=FormatNumber(isMoney,2,-1)%>', '?recharge=<%=rss("id")%>&page=<%=CurrentPage%>');">立即充值</a></td>
  </tr>
  <tr>
    <td align="center">
      
      <input type="button" class="subtm" value="确认" style="background-color:#ccc" />
      <a href="?page=<%=request("page")%>">关闭</a>
      <input type="hidden" name="t" value="y" />
      </td>
  </tr>
  <%else%>
  <tr>
    <td align="center">
      
      <input type="submit" name="button" class="subtm" value="确认" />
      <a href="?page=<%=request("page")%>">关闭</a>
      <input type="hidden" name="Itemnumber" value="<%=rss("Itemnumber")%>" />
      <input type="hidden" name="Aid" value="<%=rss("id")%>" />
      <input type="hidden" name="t" value="y" />
      </td>
  </tr>
  <%end if%>
  
  
    </form>
   <%set rss=nothing%>
  </table>
</div> 
<div class="pop_bg"></div> 
<%end if%> 






<%
if request.QueryString("recharge")<>"" then
  response.Write "<div class=""pop_content""><a href='?payment="&request("recharge")&"&page="&CurrentPage&"'>继续去付款</a> &nbsp; <a href='?payment="&request("recharge")&"&page="&CurrentPage&"'>充值已完成</a></div><div class=""pop_bg""></div>"
  response.End()
end if

if request.Form("t")="y" then
  Itemnumber=request.Form("Itemnumber")
  Aid=request.Form("Aid")
  
  '读取金额
  set rss=conn.execute("select * from auctionsorder where uid='"&uid&"' and id="&Aid&"")
    TwoMoney=((cdbl(rss("Realprice"))+cdbl(rss("TransferCost"))+cdbl(rss("TransportCost"))+cdbl(rss("ServiceCost")))*web_rate)-cdbl(rss("bail"))
	isMoney=cdbl(TwoMoney)-cdbl(money)
  set rss=nothing

  '判断余额是否满足
  if isMoney>0 then
  response.Write "<div class=""pop_content"">余额不足："&isMoney&"RMB <a target='_blank' href='/user/funds/recharge?money="&isMoney&"'>去充值</a><BR><a href='/user/auctions/order/"&id&"?page="&CurrentPage&"'>充值已完成</a></div><div class=""pop_bg""></div>"
  response.End()
  end if

  
  '资金明细写入
  set rsx=server.createobject("adodb.recordset")
  sql="select * from funds" 
  rsx.open sql,conn,1,3
  rsx.addnew  
  rsx("Uid")=uid
  rsx("money")="-"&TwoMoney
  rsx("Balance")=cdbl(money)-cdbl(TwoMoney)
  rsx("content")=Itemnumber&"付款"
  rsx("Type")=1
  rsx("PayType")=2
  rsx("mark")=1
  rsx.update
  rsx.close
  set rsx=nothing
  
  
  
  conn.execute("update auctionsorder set mark=3,rate='"&web_rate&"' where id="&Aid&"")
  conn.execute("update [user] set money=money-'"&cdbl(TwoMoney)&"' where uid='"&uid&"'")
  
  response.Write "<div class=""pop_content"">付款成功 <a href='/user/auctions/order/"&id&"?page="&CurrentPage&"'>关闭</a></div><div class=""pop_bg""></div>"
  response.End()
end if
%>







<script language=JavaScript>
var endtimes=new Array();//End Time
//endtimes[0]="4/6/2010 9:03:00";
<%=endtimes%>
var nowtimes;
function givetime(){
nowtimes=new Date("<%=now()%>");//Current Server Time
window.setTimeout("DownCount()",1000)
}
function DownCount(){
nowtimes=Number(nowtimes)+1000;
for(var i=0;i<=<%=t-1%>;i++)
{
var theDay=new Date(endtimes[i]);
theDay=theDay++;
if(theDay<=nowtimes)
{
document.getElementById("times"+i).innerHTML = "已结束";
}
else{
timechange(theDay,i);
}
}
window.setTimeout("DownCount()",1000)
}
function timechange(theDay,i){
var theDays=new Date(theDay);
var seconds = (theDays - nowtimes)/1000;
var minutes = Math.floor(seconds/60);
var hours = Math.floor(minutes/60);
var days = Math.floor(hours/24);
var CDay= days;
var CHour= hours % 24;
var CMinute= minutes % 60;
var CSecond= seconds % 60;
//var CHour=CHour+CDay*24;
if(CMinute<10)
{
CMinute="0"+CMinute;
}
if(CHour<10)
{
CHour="0"+CHour;
}
if(CSecond<10)
{
CSecond="0"+CSecond;
}
document.getElementById("times"+i).innerHTML = CDay + "天" + CHour + "时" + CMinute + "分" + CSecond + "秒";
}
</script>

</body>
</html>